/*
 * Copyright 2008 Jens Meiss
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package mtt.intro;

import java.io.IOException;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;

import mtt.menu.events.ShowMainMenuEvent;

import hmvc.j2me.framework.events.IHmvcEvent;
import hmvc.j2me.framework.events.TerminateEvent;
import hmvc.j2me.framework.view.AHmvcView;

/**
 * @author jens.meiss
 *
 */
public class IntroView extends AHmvcView {

	private Form form = new Form("Mobile-Time-Table");
	
	private Image imageWelcome;
	
	private Command commandStart = new Command("Start", Command.SCREEN, 0);
	
	public void init() {
		// TODO Auto-generated method stub
		
	}
	
	public void terminate() {
		// TODO Auto-generated method stub
		
	}

	public void handleEvent(IHmvcEvent event) {
		// TODO Auto-generated method stub
		
	}

	public void registerEvents() {
		
		try {
			imageWelcome = Image.createImage("/images/welcome.png");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		form.append(imageWelcome);
		
		form.addCommand(commandStart);
		
		form.setCommandListener(new CommandListener() {
			public void commandAction(Command c, Displayable d) {
				getHmvcController().fireEventUp(new ShowMainMenuEvent());
				getHmvcController().fireEventLocal(new TerminateEvent());
			}
		});
		
		setDisplayable(form);
		
	}
}
